package com.suse.config;

import com.suse.util.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

/**
 * 拦截器配置
 */
@Configuration
public class MyInterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        List<String> list = new ArrayList<>();
        // 配置拦截index地址
        list.add("/index");
        list.add("/info");
        // 注册LoginInterceptor 配置拦截哪些地址
        registry.addInterceptor(new LoginInterceptor()).addPathPatterns(list);
    }
}
